import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import fs from 'fs-extra';
import path from 'path';
// import legacy from '@vitejs/plugin-legacy'
// https://vitejs.dev/config/
function copyFile() {
	console.log(process.env.UNI_PLATFORM, 'test123')
	return {
		enforce: 'post',
		async writeBundle() {
			await fs.copy(
				path.resolve(__dirname, 'images'),
				path.join(
					__dirname,
					'unpackage/dist',
					process.env.NODE_ENV === 'production' ? 'build' : 'dev',
					process.env.UNI_PLATFORM,
					'images'
				)
			);
		},
	};
}
export default defineConfig({
  plugins: [
    uni(),
	copyFile()
  ],
  css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@import '@/uni.scss';@import 'uview-plus/theme.scss';`,
        },
      },
    },
})
